/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.suspend.local;

import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.text.TextUtils;
import android.view.View;
import com.qihoo.gamecenter.sdk.suspend.remote.IQRemoteService;
import com.qihoo.stat.QHStatDo;

public class QLocalService extends Service {
    private static String b = "";
    private static String c = "";
    private static String d;
    private boolean e = false;
    private View f;
    private BroadcastReceiver g = new BroadcastReceiver() {
        public void onReceive(Context paramContext, Intent paramIntent) {
            if (paramIntent == null)
                return;
            String str1 = paramIntent.getStringExtra("360floatsdk.stat.action.param.pkgname");
            String str2 = paramIntent.getStringExtra("360floatsdk.stat.action.param.event");
            if ((TextUtils.isEmpty(str1)) || (TextUtils.isEmpty(str2))
                    || (!(QLocalService.this.getApplicationContext().getPackageName().equals(str1))))
                return;
            QHStatDo.event(QLocalService.this.getApplicationContext(), str2, null);
        }
    };
    public static String a = null;

    public void onCreate() {
        super.onCreate();
        com.qihoo.gamecenter.sdk.suspend.b.b.a("QLocalService", " come to  onCreate.");
        a(getApplicationContext());
        this.f = new View(this);
        b.a(getApplicationContext(), this.g);
    }

    public int onStartCommand(Intent paramIntent, int paramInt1, int paramInt2) {
        super.onStartCommand(paramIntent, paramInt1, paramInt2);
        com.qihoo.gamecenter.sdk.suspend.b.b.a("QLocalService", " come to  onStartCommand.");
        if (paramIntent != null) {
            b = paramIntent.getStringExtra("fQid");
            c = paramIntent.getStringExtra("fQt");
            d = paramIntent.getStringExtra("loginPkgname");
            com.qihoo.gamecenter.sdk.suspend.b.b.a("QLocalService", "  \nmQid : " + b + "  \nmQt : " + c
                    + "  \nLoginedPkgname " + d);
            if (!(TextUtils.isEmpty(d))) {
                if (TextUtils.isEmpty(b))
                    b = "";
                if (TextUtils.isEmpty(c))
                    c = "";
                com.qihoo.gamecenter.sdk.suspend.c.a.b(getApplicationContext(), d, b);
                com.qihoo.gamecenter.sdk.suspend.c.a.a(getApplicationContext(), d, c);
                a(d);
                if (a.a() != null)
                    try {
                        a.a().updateLoginedState(d, b, c);
                    } catch (RemoteException localRemoteException) {
                        localRemoteException.printStackTrace();
                    } catch (Throwable localThrowable) {
                        localThrowable.printStackTrace();
                    }
            }
        }
        return 1;
    }

    private void a(String paramString) {
        if (TextUtils.isEmpty(paramString))
            return;
        if (TextUtils.isEmpty(a))
            a = com.qihoo.gamecenter.sdk.suspend.c.a.e(getApplicationContext());
        if (TextUtils.isEmpty(a)) {
            a = ":" + paramString + ":";
            com.qihoo.gamecenter.sdk.suspend.c.a.f(getApplicationContext(), a);
        }
        else {
            if (a.contains(paramString))
                return;
            a = a + paramString + ":";
            com.qihoo.gamecenter.sdk.suspend.c.a.f(getApplicationContext(), a);
        }
    }

    public void onDestroy() {
        super.onDestroy();
        b = "";
        c = "";
        b.b(getApplicationContext(), this.g);
    }

    public IBinder onBind(Intent paramIntent) {
        return null;
    }

    protected static void a(Context paramContext) {
        com.qihoo.gamecenter.sdk.suspend.b.b.a("QLocalService", " come to  bindRemote.");
        Intent localIntent = new Intent("com.qihoo.gamecenter.sdk.suspend.service.action.remote");
        localIntent.putExtra("fQid", b);
        localIntent.putExtra("fQt", c);
        localIntent.putExtra("loginPkgname", d);
        paramContext.bindService(localIntent, new a(paramContext), 1);
    }
}